﻿@using Microsoft.AspNetCore.Routing
@using WB.Core.GenericSubdomains.Portable
@using WB.Core.SharedKernels.SurveySolutions.Api.Designer
@model IEnumerable<WB.Core.BoundedContexts.Designer.QuestionnaireCompilationForOldVersions.QuestionnaireCompilationVersion>

@{
    ViewBag.Title = "Compilation Versions";
    Layout = "Layout.ControlPanel";
}

<h2>Questionnaire Compilation Versions <a class="btn btn-default" href="@Url.Action("AddCompilationVersion","ControlPanel")">Add</a></h2>
<table class="table table-striped">
    <thead>
        <tr>
            <th>Questionnaire</th>
            <th>Version</th>
            <th>Description</th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    @if (Model != null)
    {
        foreach (var compilationVersion in Model)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary { { "id", compilationVersion.QuestionnaireId.FormatGuid() } };
            <tr>
                <td>
                    @Html.ActionLink(compilationVersion.QuestionnaireId.FormatGuid(), "Details", "Questionnaire", routeValues, null)
                </td>
                <td><span title="Version that is going to be used when compiling">@compilationVersion.Version</span> / <span title="Questionnaire content version">@ApiVersion.MaxQuestionnaireVersion</span></td>
                <td>@compilationVersion.Description</td>
                <td>
                    <a href="@Url.Action("EditCompilationVersion", "ControlPanel", new { id = compilationVersion.QuestionnaireId })" class="btn btn-link">Edit</a>
                </td>
                <td>
                    <form asp-action="RemoveCompilationVersion" asp-controller="ControlPanel" method="post">
                        @Html.AntiForgeryToken()
                        @Html.Hidden("QuestionnaireId", compilationVersion.QuestionnaireId)
                        <button type="submit" class="btn btn-link">Remove</button>
                    </form>
                </td>
            </tr>
        }
    }
    </tbody>
</table>
